
class httpQueryParser:
    def __init__(self, theString):
        self.theString = theString
        self.parseString()
        self.dict = {}

    def getString(self):
        return self.theString

    def getDict(self):
        return self.dict

    def parseString(self):
        s = self.theString
        loc = s.find("?")
        s = s[loc+1:]
        while (len(s) != 0):
            loc = s.find("=")
            loc2 = s.find("&")
            key = s[:loc]
            value = s[loc+1:loc2]
            self.dict[key] = value
            s = s[loc2+1:]

    def getValue(self, s):
        if self.dict.has_key(s):
            return self.dict[s]
        else:
            return -1

if __name__=="__main__":
    parser = httpQueryParser("http://www.ru.is/?course=hugb&exercise=tdd")
